<template>
  <div class="wrap">
    <!-- 搜索 -->
    <el-card style="width: 20%; height: 100%">
      <!-- 表单搜索 -->
      <!-- <el-form size="mini" ref="batchJsForm" :label-width="formLabelWidth"> -->
      <!-- 表头查询 -->
      <!-- 第一行 -->
      <el-row type="flex" justify="start">
        <el-form size="mini" ref="batchJsForm" :label-width="formLabelWidth">
          <FuzzyQueryInput
            @inputChange="inputChange"
            ref="queryInput"
            prop="stationName"
            :api="queryStationNameList"
            @handleClear="handleClear"
          />
        </el-form>
        <!-- <FuzzyQueryInput :api="queryUnitsNameList" labelText="机组名称" /> -->
      </el-row>
      <div style="height: 100%">
        <el-tree
          :data="dataTree"
          ref="equipmentTree"
          @check="handleCheck"
          @check-change="checkChange"
          :props="defaultProps"
          node-key="id"
          :default-expanded-keys="checkList"
          width="75%"
          show-checkbox
        ></el-tree>
        <!-- node-key="id" -->
      </div>
      <!-- </el-form> -->
      <!-- @check-change="checkChange"  -->
    </el-card>
    <!-- 表格 -->
    <el-card style="margin-left: 20px; width: 80%">
      <el-form
        style="width: 100%; margin-top: 1%"
        ref="photovoltaic"
        label-width="110px"
        size="mini"
      >
        <el-row type="flex" justify="space-between">
          <el-col :span="6">
            <el-form-item label="测试日期:">
              <el-date-picker
                v-model="queryDetailParam.testDate"
                type="date"
                :value-format="'yyyy-MM-dd'"
                placeholder="选择日期"
                @change="testDateChange(queryDetailParam.testDate)"
              >
              </el-date-picker>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="测试序号:">
              <el-select
                v-model="queryDetailParam.testNumber"
                placeholder="请选择"
                clearable
                :popper-append-to-body="false"
                style="width: 90%"
                :disabled="!queryDetailParam.testDate"
              >
                <el-option
                  v-for="item in testNumberList"
                  :key="item.value"
                  :label="item.label"
                  :value="item.label"
                >
                </el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="审核是否通过:">
              <el-select
                v-model="queryDetailParam.isAudited"
                placeholder="请选择"
                :popper-append-to-body="false"
                style="width: 90%"
                clearable
              >
                <el-option
                  v-for="item in isYes"
                  :key="item.value"
                  :label="item.label"
                  :value="item.value"
                >
                </el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-button
              type="primary"
              size="mini"
              style="margin: 1px 0 0 3%"
              @click="searchOrder"
              >检索</el-button
            >
            <el-button size="mini" @click="resetSearchList">重置</el-button>
          </el-col>
        </el-row>
      </el-form>
      <CleanForm
        :searShow="true"
        :showColumnHandle="false"
        :api="queryStationFileList"
        :queryParam="queryDetailParam"
        :fieldList="headList"
        :tableOptionWidth="200"
        :showColumnSetting="false"
        :page="false"
        :dialogPage="true"
        :showExportBtn="false"
        ref="windPowerTable"
        style="width: 100%; height: 100%"
      >
        <template slot="tableTopOptionRight">
          <!-- 这里是写表格上方的按钮 -->
          <div>
            <span class="operateButton" @click="addWindPower" operate="add"
              ><img src="@/assets/icon/389.png" /> 新增</span
            >
            <!-- <span
              class="operateButton b-border"
              @click="copyWindPower()"
              operate="copy"
              ><img src="@/assets/icon/394.png" /> 复制</span
            > -->
            <span
              class="operateButton b-border"
              @click="editWindPower()"
              operate="edit"
              ><img src="@/assets/icon/392.png" /> 编辑</span
            >
            <span
              class="operateButton b-border"
              @click="deleteWindPower()"
              operate="delete"
              ><img src="@/assets/icon/393.png" /> 删除</span
            >
            <span
              class="operateButton b-border"
              @click="exportExcel()"
              operate="export"
              ><img src="@/assets/icon/395.png" /> 导出</span
            >
          </div>
        </template>
      </CleanForm>
    </el-card>
    <!-- 新增弹框 -->
    <div v-if="dialogFormVisible">
      <el-dialog
        :title="addDialogVisibleTitle"
        :visible.sync="dialogFormVisible"
        width="1500px"
        top="7vh"
      >
        <test-result-edit
          ref="childRules"
          :detailForm="getFrom"
          :dispatchLists="dispatchList"
          :stationTypeLists="stationTypeLists"
          :voltageLevelLists="voltageLevelLists"
          :adjustRegulationLists="adjustRegulationLists"
          :queryDetailParam="queryDetailParam"
          :operate="operate"
        ></test-result-edit>
        <div slot="footer" class="dialog-footer">
          <el-button type="primary" size="small" @click="saveForm()">{{
            this.addDialogVisibleTitle == "编辑" ? "确认编辑" : "确认新增"
          }}</el-button>
          <el-button
            type="primary"
            v-if="this.addDialogVisibleTitle != '编辑'"
            size="small"
            @click="resetCon()"
            >重置
          </el-button>
          <el-button size="small" @click="dialogFormVisible = false"
            >退出
          </el-button>
        </div>
      </el-dialog>
    </div>
    <!-- 预览弹框 -->
    <el-dialog
      title="预览"
      width="70%"
      :visible.sync="dialogPreVisible"
      @opened="openMethods()"
      @close="
        () => {
          pdf = '';
        }
      "
    >
      <iframe
        style="width: 100%; height: 450px"
        frameborder="0"
        width="100%"
        height="620px"
        :src="pdf"
        v-if="pdf"
        type="application/x-google-chrome-pdf"
        ref="previewFrame"
      ></iframe>
      <div
        class="table-html-wrap"
        v-if="!pdf"
        :key="key"
        style="width: 100%; height: 420px; overflow: auto"
        id="tableHtml"
      ></div>

      <!-- && showXLSX==false


    <div v-if="showXLSX" id="luckysheet" style="padding: 0px;width: 100%; left: 0px; top: 10px; bottom: 10px; height: 620px;"></div> -->
    </el-dialog>
  </div>
</template>
<script>
import TestResult from "./testResult.js";
export default TestResult;
</script>
<style lang="scss" scoped>
::v-deep .el-tree {
  height: 100% !important;
  overflow-x: auto !important;
}

::v-deep .el-card__body {
  height: calc(95% - 20px) !important;
}

::v-deep .el-tree-node:focus > .el-tree-node__content {
  background-color: #f2f2f2;
}
.table-html-wrap {
  overflow: hidden;
  overflow-y: auto;
}

.table-html-wrap ::v-deep table {
  // color: red;
  border-right: 1px solid #000;
  border-bottom: 1px solid #000;
  border-collapse: collapse;
  margin: auto;
}

.table-html-wrap ::v-deep table td {
  border-left: 1px solid #000;
  border-top: 1px solid #000;
  white-space: nowrap;
  text-align: center;
  padding: 0.5rem;
}

.table-html-wrap ::v-deep tbody tr:nth-of-type(1) {
  font-weight: bold;
  font-size: 20px;
}

.dialog-footer {
  text-align: end;
}

.wrap {
  width: 100%;
  height: 100%;
  display: flex;

  /* background-color: rgb(195, 188, 241); */
}

.title {
  border: 1px solid grey;
  border-radius: 4px;
  width: 200px;
  text-align: center;
}

.operateButton {
  cursor: pointer;
  font-size: 12px !important;
  padding: 8px;

  img {
    transform: translateY(-2px);
  }
}

.operateButton::after {
  display: inline-block;
  content: "";
  width: 1px;
  height: 18px;
  margin: 0 3px;
  transform: translate(6px, 3px);
  background: #000;
}

.operateButton:last-child::after {
  display: none;
}

::v-deep .el-select--mini {
  width: 100%;
}

::v-deep .el-date-editor {
  width: 100%;
}

::v-deep .el-scrollbar__thumb {
  background: #000;
  display: none;
}

// ::-webkit-scrollbar-thumb {
//   // display: none;
// }
::v-deep .el-table__empty-block {
  justify-content: left;
  text-align: left;
  padding-left: 40%;
}

::v-deep .el-select-dropdown {
  position: absolute !important;
  top: 80% !important;
  left: 0px !important;
}

::v-deep .el-card {
  border-radius: 4px;
  border: 1px solid #ebeef5;
  background-color: #fff;
  overflow: visible !important; //溢出不隐藏   隐藏的话，下拉框看不到全部数据
  color: #303133;
  transition: 0.3s;
  height: 100%;
}
</style>
